import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { BaseResponse } from '@/api/base';

// 定义接口地址
enum Api {
  /** 待导入Api */
  CANDIDATES = '/toolkit/api/candidates',
  /** 批量导入 */
  IMPORTS = '/toolkit/api/imports',
  /** 同步 */
  SYNC = '/toolkit/api/sync',
}

// 定义参数类型

export interface ApiPO {
  id?: number;
  creator?: String;
  createTime?: Date;
  updater?: String;
  updateTime?: Date;
  moduleName?: String;
  className?: String;
  classCanonicalName?: String;
  methodName?: String;
  methodDescription?: String;
  httpMethod?: String;
  requestUri?: String;
  perms?: String;
  status?: number;
}

export interface ApiQuery {
  id?: number;
  creator?: String;
  createTime?: Date;
  updater?: String;
  updateTime?: Date;
  moduleName?: String;
  className?: String;
  classCanonicalName?: String;
  methodName?: String;
  methodDescription?: String;
  httpMethod?: String;
  requestUri?: String;
  perms?: String;
  status?: number;
}

// 定义接口方法
// 待导入Api
export function candidates(params: ApiQuery, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<Array<ApiPO>>>(
    {
      url: Api.CANDIDATES,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 批量导入
export function imports(params: string[], mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<boolean>>(
    {
      url: Api.IMPORTS,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 同步
export function sync(params: String, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<boolean>>(
    {
      url: Api.SYNC,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

